package com.ghck.server.dao;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.ghck.server.dao.provider.AjkAccountProvider;
import com.ghck.server.model.AjkAccount;
import com.ghck.server.model.query.AjkAccountQuery;
/**
 * 账号接口认证表  <br>
 * ajk_account <br>
 * v1.0 2016-05-01
 */
 public interface AjkAccountMapper {
 	
 	/**
 	*根据id删除 账号接口认证表
 	*/
 	@Delete("delete from ajk_account where id=#{id}")
 	public Integer deleteById(Integer id);
 	
 	/**
 	* 批量新增 账号接口认证表
 	*/
 	@InsertProvider(method="batchInsert",type=AjkAccountProvider.class)
	@Options(useGeneratedKeys=true,keyColumn="id",keyProperty="list[0].id")
 	public Integer batchInsert(List<? extends AjkAccount> ajkAccounts);
 	
 	/**
 	* 新增 账号接口认证表
 	*/
 	@InsertProvider(method="insert",type=AjkAccountProvider.class)
	@Options(useGeneratedKeys=true)
 	public Integer insert(AjkAccount domain);
 
 	
 	/**
 	*更新 账号接口认证表
 	*/
 	@UpdateProvider(method="update",type=AjkAccountProvider.class)
 	public Integer update(AjkAccount domain);
 	
 	/**
 	*根据ID查询 账号接口认证表
 	*/
	@Select("select * from ajk_account where id=#{id}")
	public AjkAccount findById(Integer id);
	
	/**
 	*通过query 查询 账号接口认证表
 	*/
 	@SelectProvider(method="findByQuery",type=AjkAccountProvider.class)
 	public List<AjkAccount> findByQuery(AjkAccountQuery query);
 	
 	/**
 	*通过query count总条数
 	*/
 	@SelectProvider(method="countByQuery",type=AjkAccountProvider.class)
 	public Integer countByQuery(AjkAccountQuery query);
 	
 	/**
 	* 通过ids查询
 	*/
 	@SelectProvider(method="findByIds",type=AjkAccountProvider.class)
 	public List<AjkAccount> findByIds(List<Integer> ids);
 	
 	@Select("select * from ajk_account where access_id = #{accessId}")
 	public AjkAccount findByAccessId(String accessId);
 	
	@Select("select * from ajk_account where access_key = #{accessKey}")
 	public AjkAccount findByAccessKey(String accessKey);
	
	@Select("select * from ajk_account where user_id = #{userId}")
	public AjkAccount findByUserId(Integer userId);
	
	@SelectProvider(method="findByUserIds",type=AjkAccountProvider.class)
 	public List<AjkAccount> findByUserIds(List<Integer> ids);
 	
 	
}	